
FROM golang:1.21.3 as builder


WORKDIR /app
COPY . /app
RUN CGO_ENABLED=0 go build  -o topdf


FROM alpine:3.19

# 更新源
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories

# 安装依赖
RUN apk add --no-cache libreoffice font-noto-cjk

# 设置时区
RUN apk add --no-cache tzdata 
ENV TZ=Asia/Shanghai

# 设置工作目录
WORKDIR /app
COPY --from=builder /app/topdf /app/topdf
COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt

EXPOSE 8080
CMD [ "/app/topdf" ]

